package data

import (
	"context"
	"fmt"
	"helloworld/app/user/service/internal/conf"

	"github.com/go-kratos/kratos/v2/log"
	"github.com/redis/go-redis/v9"
)

func NewRedis(conf *conf.Data, loggers log.Logger) *redis.Client {
	rdb := redis.NewClient(&redis.Options{
		Addr:     conf.Redis.Addr,
		Password: "", // no password set
		DB:       0,  // use default DB
	})
	ctx := context.Background()
	rdb.Set(ctx, "testKey", "1111111", 0)
	val, err := rdb.Get(ctx, "testKey").Result()
	fmt.Println(val)
	if err != nil {
		panic(err)
	}
	return rdb
}
